package com.ufaud.ais.sys.webapp.action;

import com.ufaud.ais.pub.webapp.action.JQueryTreeViewAction;
import com.ufaud.ais.sys.entity.Department;
import com.ufaud.ais.sys.service.IDepartmentService;

public class DeptTreeAction extends JQueryTreeViewAction<Department> {

	private IDepartmentService deptService;

	public String getTree() throws Exception {
		putUrl("查看", "${ctx}/sys/dept/toAction/view.action?id=${id}");
		putUrl("删除", "javascript:ajaxDelete('${ctx}/ajax/dept/doDelete.action?id=${id}', '是否确认删除部门【${text}】?')");
		return execute();
	}
	
	public String deptInEmployeeUI() throws Exception {
		putUrl("查看部门人员", "${ctx}/sys/employee/list.action?deptId=${id}");
		return execute();
	}

	@Override
	protected String getChildrenFieldName() {
		return "subDeptSet";
	}

	@Override
	protected String getIdFieldName() {
		return "deptId";
	}

	@Override
	protected String getTextFieldName() {
		return "deptName";
	}

	@Override
	protected Department loadActualObject() {
		return deptService.getAllDepartmentInTreeStructure();
	}

	public void setDeptService(IDepartmentService deptService) {
		this.deptService = deptService;
	}

}
